package tech.novastar.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class JdbcUtil {
    private final static Logger logger =  LoggerFactory.getLogger(JdbcUtil.class);
    public static Connection getConnection() {
        Properties config = PropertiesUtil.getConfig();
        try {
            Class.forName(config.getProperty("db_class"));
            String url = config.getProperty("db_url");
            String username = config.getProperty("db_user");
            String password = config.getProperty("db_pass");
            return DriverManager.getConnection(url, username, password);
        } catch (ClassNotFoundException | SQLException e) {
            logger.error(e.getLocalizedMessage());
        }
        return null;
    }
}
